package net.cyndeline.game.defaultImpl

import scala.actors.Actor
import net.cyndeline.entitySystem.EventSystem
import net.cyndeline.game.EventProcessor

/**
 * Processes events in an infinite loop until
 * told to stop.
 */
class EventProcessorImpl extends EventProcessor {

  def act() {
    loop {
      react {
        case ProcessCycle(system) => {
          system.process
          
          this ! (ProcessCycle(system))
        }
        
        case StopEventProcessing => exit()
      }
    }
  }
  
  
}

/* Messages. */
case class ProcessCycle(system: EventSystem)
case class StopEventProcessing()